<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:param name="category"/>
    <xsl:template match="/">
        <html>
            <head>
                <link rel="stylesheet" type="text/css" href="../css/style.css"/>
            </head>

            <body>
                <h2>
                    List of subcategories of category
                    <xsl:value-of select="$category"/>:
                </h2>
                <div class = "blockCenter">
                    <ul><xsl:apply-templates/></ul>
                </div>
                <form action="/servlet" class="blockCenter">
                    <input type="submit" name="command" value="BACK" class="button"/>
                    <!--<input type="hidden" name="command" value="back"/>-->
                    <input type="hidden" name="page" value="categoryList"/>
                </form>
            </body>
        </html>
    </xsl:template>

    <xsl:template match="category">
        <xsl:if test="@name = $category">
            <xsl:apply-templates select="subcategory"/>
        </xsl:if>
    </xsl:template>

    <xsl:template match="subcategory">
        <xsl:variable name="nam" select="@name"/>
        <xsl:variable name="count" select="count(//category/subcategory[@name = $nam]/goods)"/>
        <li>
            <a href="/servlet?command=show&amp;category={$category}&amp;subcategory={@name}&amp;type=goodsList">
                <xsl:value-of select="$nam"/>(<xsl:value-of select="$count"/>)
            </a>
        </li>
    </xsl:template>
</xsl:stylesheet>